﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class IUserInput : MonoBehaviour
{
    public float Dup;
    public float Dright;
    public float Jup;
    public float Jright;

    public Vector3 vec;
    public float mag;

    public bool isRun;
    public bool isJump;
    public bool lb;
    public bool rb;
    public bool isDefend;
    public bool isLockOn;

    public bool enabledInput = true;

    protected float targetDright;
    protected float targetDup;
    protected float drightVelocity;
    protected float dupVelocity;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public Vector2 SquareToCircle(float x, float y)
    {
        Vector2 output = Vector2.zero;
        output.x = x * Mathf.Sqrt(1 - (y * y) / 2);
        output.y = y * Mathf.Sqrt(1 - (x * x) / 2);
        return output;
    }

   public void CalDmagDvec() {
        Vector2 output = SquareToCircle(Dright, Dup);
        vec = transform.forward * output.y + transform.right * output.x;
        mag = Mathf.Sqrt(output.x * output.x + output.y * output.y);
    }

    public void CalDmagDvec(Transform transform = null)
    {
        Vector2 output = SquareToCircle(Dright, Dup);
        //vec = transform.forward * output.y + transform.right * output.x;
        vec = new Vector3(output.x, 0, output.y);
        mag = Mathf.Sqrt(output.x * output.x + output.y * output.y);
    }
}
